package com.ai.dao;

import java.sql.SQLException;

import com.ai.dbutil.DBconn;
import com.ai.entity.Course;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;

public class CourseDao {
	public int addCourse(Course course) {
		Connection conn = DBconn.getInstance();
		int i = 0;
		String sql = "insert into course (NAME) values (?)";
		PreparedStatement pstmt;
		try {
	        pstmt = (PreparedStatement) conn.prepareStatement(sql);
	        pstmt.setString(1, course.getName());
	        i = pstmt.executeUpdate();
	        pstmt.close();
	        conn.close();
	    } catch (SQLException e) {
	        e.printStackTrace();
	    }	
	    return i;
	}
}
